package handlers

import (
	"net/http"
	"runtime"

	"github.com/gin-gonic/gin"
)

type VersionInfo struct {
	Version   string `json:"version"`
	BuildTime string `json:"buildTime"`
	GoVersion string `json:"goVersion"`
}

// 这些变量将在编译时通过 -ldflags 注入
var (
	Version   = "dev"
	BuildTime = "unknown"
)

func GetVersion(c *gin.Context) {
	versionInfo := VersionInfo{
		Version:   Version,
		BuildTime: BuildTime,
		GoVersion: runtime.Version(),
	}
	c.JSON(http.StatusOK, versionInfo)
}
